<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>

</head>
<style>
    li{
        list-style-type: none;
    }

</style>
<body>
    <div id="app">
        <div class="box">
            <div class="top">
                <input type="text" v-model="message">
                <button @click="add1()">添加任务</button>
            </div>
            <ul>
                <li v-for="(item,index) in list" >{{index+1}}. {{item}} <button @click="del(index)">x</button></li>
            </ul>
        </div>
        <div v-show="list.length>0">
            <span>{{list.length}}</span>
            <button @click="clear()">clear</button>
        </div>
    </div>
</body>
<script>
    const app=new Vue({
        el:"#app",
        data:{
            message:"",
            list:[],
        },
        methods: {
            add1(){
                this.list.push(this.message);
                this.message=""
            },
            del(i){
                this.list.splice(i,1)
            },
            clear(){
                this.list=[];
            }   
        }

    })
</script>
</html>